from google.appengine.ext import db

encoding_supported = ['JPG','JPEG','PNG','GIF','BMP','TIFF','ICO']
fileext_supported = ['jpg','jpeg','png','gif','bmp','tiff','ico']

class Error(Exception):
  """Base-class for exceptions in this module."""

class NotSupportedImageEncodingError(Error):
  """The image encoding is not supported is invalid."""

class Img(db.Model):
    uploader = db.UserProperty()
    imgId = db.StringProperty()
    contentType = db.StringProperty()
    contentLength = db.IntegerProperty()
    content = db.BlobProperty()
    thumbnail = db.BlobProperty()
    accessTimes = db.IntegerProperty()
    date = db.DateTimeProperty(auto_now_add=True)
    originalURL = db.StringProperty()

    @staticmethod
    def isSupported(encoding):
        return encoding in encoding_supported
    
